<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
//后台模块
Route::group(['prefix'=>'admin','namespace'=>'Admin','as'=>'admin.'],function (){
    //后台登录显示
    Route::get('login','LoginController@index')->name('login');
    //后台登录处理
    Route::post('login','LoginController@login')->name('login')->middleware('loginlog');
    //创建Es索引的路由
    Route::get('es/create','EsController@create')->name('admin.es.create');
    Route::group(['middleware'=>['checkadminlogin']],function (){
        // 后台首页
        Route::get('index', 'IndexController@index')->name('index');
        // 欢迎页
        Route::get('welcome', 'IndexController@welcome')->name('welcome');

        // 后台用户退出
        Route::get('logout','IndexController@logout')->name('logout');
        //用户管理
        //用户列表
        Route::get('user/index','AdminController@index')->name('admin.index');
        //添加用户显示
        Route::get('user/create','AdminController@create')->name('admin.create');
        //添加用户处理
        Route::post('user/store','AdminController@store')->name('admin.store');
        //修改用户显示
        Route::get('user/edit/{id}','AdminController@edit')->name('admin.edit');
        //修改用户处理
        Route::put('user/update/{id}','AdminController@update')->name('admin.update');
        //删除单个用户
        Route::delete('user/del/{id}','AdminController@del')->name('admin.del');
        //删除所选用户
        Route::get('user/delAll','AdminController@delAll')->name('admin.delAll');
        //恢复单个用户
        Route::get('user/restore/{id}','AdminController@restore')->name('admin.restore');
        //个人信息展示
        Route::get('center/{id}','AdminController@center')->name('center');
        //角色管理
//        //角色添加显示
//        Route::get('role/create','RoleController@create')->name('role.create');
//        //角色添加处理
//        Route::post('role/store','RoleController@store')->name('role.store');
        Route::match(['get','post'],'role/auth/{role}','RoleController@auth')->name('role.auth');
        //资源路由 curd操作路由
        Route::resource('role','RoleController');
        Route::resource('node','NodeController');

        //文章管理
        //文件上传
        Route::post('article/upfile','ArticleController@upfile')->name('article.upfile');
        //删除上传图片
        Route::get('article/delpic','ArticleController@delpic')->name('article.delpic');
        //文章访问统计
        Route::get('article/count','ArticleController@count')->name('article.count');
        //文章管理
        Route::resource('article','ArticleController');

        //房源属性管理
        //文件上传
        Route::post('fangattr/upfile','FangattrController@upfile')->name('fangattr.upfile');
        //删除上传图片
        Route::get('fangattr/delpic','FangattrController@delpic')->name('fangattr.delpic');
        Route::resource('fangattr','FangattrController');

        //房东管理
        //导出excel
        Route::get('fangowner/excel','FangownerController@excel')->name('fangowner.excel');
        //生成excel
        Route::get('fangowner/createexcel','FangownerController@createexcel')->name('fangowner.createexcel');
        //文件上传
        Route::post('fangowner/upfile','FangownerController@upfile')->name('fangowner.upfile');
        //删除上传图片
        Route::get('fangowner/delpic','FangownerController@delpic')->name('fangowner.delpic');
        Route::resource('fangowner','FangownerController');

        //三级联动数据处理路由
        Route::get('fang/area','FangController@area')->name('fang.area');
        //图片上传
        Route::post('fang/upfile','FangController@upfile')->name('fang.upfile');
        //添加租房记录显示
        Route::get('fang/rent/{fang}','FangController@rent')->name('fang.rent');
        //添加租房处理
        Route::post('fang/rent/{fang}','FangController@rentStore')->name('fang.rent');
        //房源管理
        Route::resource('fang','FangController');

        //预约管理
        Route::resource('notice','NoticeController');

        //接口账号管理
        Route::resource('apiuser','ApiuserController');

        //租客管理
        //租客房源收藏
        Route::get('renting/fav/{renting}','RentingController@fav')->name('renting.fav');
        Route::resource('renting','RentingController');
    });
});
